import axios from 'axios';
// axios.defaults.withCredentials=true;

let host = window.location.host;

let setHost = (host) => {
    switch(host){
        case 'localhost:5050': return 'http://192.168.1.63:8088';
        case '192.168.1.45:5050': return 'http://192.168.1.63:8088';
        case '192.168.4.41': return 'http://192.168.4.41';
        // default: return 'http://202.98.194.146:8888';
        default: return 'http://192.168.1.63:8088';
    }
}
const base = setHost(host) + '/video/public/index.php';

/**
 * 图片上传地址
 */
export const action = base+'/admin/subjectadmin/uploadfileinfo';
export const imgBaseUrl = setHost(host)+'/video/public/static/';

/**
 * 收藏模块
 */
export const storefrontAdd = params => { return axios.get(`${base}/user/storefront/add`, {params: params}).then(res => res.data); };
export const storefrontDel = params => { return axios.get(`${base}/user/storefront/del`, {params: params}).then(res => res.data); };
export const storefrontGetlist = params => { return axios.get(`${base}/user/storefront/getlist`, {params: params}).then(res => res.data); };

/**
 * 用户模块
 */
export const submit = params => { return axios.post(`${base}/user/userfront/submit`, params).then(res => res.data); }; 
// export const submit = params => { return axios.get(`${base}/user/userfront/submit`, {params: params}).then(res => res.data); }; 
export const logout = params => { return axios.get(`${base}/user/userfront/logout`, {params: params}).then(res => res.data); }; 
export const update = params => { return axios.get(`${base}/user/userfront/update`, {params: params}).then(res => res.data); }; 
export const resetpw = params => { return axios.get(`${base}/user/userfront/resetpw`, {params: params}).then(res => res.data); }; 
export const check = params => { return axios.get(`${base}/user/userfront/check`, {params: params}).then(res => res.data); }; 
export const register = params => { return axios.get(`${base}/user/userfront/register`, {params: params}).then(res => res.data); }; 

export const forget_check = params => { return axios.get(`${base}/user/userfront/forget_check`, {params: params}).then(res => res.data); }; 
export const forget_reset = params => { return axios.get(`${base}/user/userfront/forget_reset`, {params: params}).then(res => res.data); }; 

/**
 * 视频模块
 */
export const getmenuvideo = params => { return axios.get(`${base}/article/articlefront/getmenuvideo`, {params: params}).then(res => res.data); };
export const getmenuhotvideo = params => { return axios.get(`${base}/article/articlefront/getmenuhotvideo`, {params: params}).then(res => res.data); };
export const getmenurecommvideo = params => { return axios.get(`${base}/article/articlefront/getmenurecommvideo`, {params: params}).then(res => res.data); };
export const updategood = params => { return axios.get(`${base}/article/articlefront/updategood`, {params: params}).then(res => res.data); };
export const videodetail = params => { return axios.get(`${base}/article/articlefront/videodetail`, {params: params}).then(res => res.data); };
export const billboard = params => { return axios.get(`${base}/article/articlefront/billboard`, {params: params}).then(res => res.data); };
/**
 * IP模块
 */
export const IPGetlist = params => { return axios.get(`${base}/ip/ipfront/getlist`, {params: params}).then(res => res.data); };
export const IPGetarticlelist = params => { return axios.get(`${base}/ip/ipfront/getarticlelist`, {params: params}).then(res => res.data); };
export const IPGethotiplist = params => { return axios.get(`${base}/ip/ipfront/gethotiplist`, {params: params}).then(res => res.data); };

/**
 * 话题模块
 */
export const topicGetlist = params => { return axios.get(`${base}/topic/topicfront/getlist`, {params: params}).then(res => res.data); };
export const topicGetarticlelist = params => { return axios.get(`${base}/topic/topicfront/getarticlelist`, {params: params}).then(res => res.data); };

/**
 * 专题模块
 */
export const subjectGetlist = params => { return axios.get(`${base}/subject/subjectfront/getlist`, {params: params}).then(res => res.data); };
export const subjectGetarticlelist = params => { return axios.get(`${base}/subject/subjectfront/getarticlelist`, {params: params}).then(res => res.data); };

/**
 * 菜单管理
 */
export const getmenu = params => { return axios.get(`${base}/menu/index/getmenu`, {params: params}).then(res => res.data); };

/**
 * 评论管理
 */
// export const commentGetlist = params => { return axios.get(`${base}/comment/index/adminlist`, {params: params}).then(res => res.data); };
// export const commentCheck = params => { return axios.get(`${base}/comment/index/admincheck`, {params: params}).then(res => res.data); };
export const commentAdd = params => { return axios.get(`${base}/comment/index/add`, {params: params}).then(res => res.data); };
export const commentArticlecomment = params => { return axios.get(`${base}/comment/index/articlecomment`, {params: params}).then(res => res.data); };

/**
 * 首页模块
 */
export const indexpage = params => { return axios.get(`${base}/article/articlefront/indexpage`, {params: params}).then(res => res.data); };

/**
 * 订阅
 */
export const subscriptionAdd = params => { return axios.get(`${base}/subscription/subscriptionfront/add`, {params: params}).then(res => res.data); };
export const subscriptionDel = params => { return axios.get(`${base}/subscription/subscriptionfront/del`, {params: params}).then(res => res.data); };
export const subscriptionGetlist = params => { return axios.get(`${base}/subscription/subscriptionfront/getlist`, {params: params}).then(res => res.data); };






